//
//  EPMPhotoCell.m
//  WeiBoByOC
//
//  Created by 马继鵬 on 17/3/29.
//  Copyright © 2017年 7TH. All rights reserved.
//

#import "EPMPhotoCell.h"

@interface EPMPhotoCell()
@property (weak,nonatomic)  UIImageView* imgView;
@property (weak,nonatomic) UIImageView* imgGif;
@end
@implementation EPMPhotoCell
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]){
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    
    UIImageView* imgView = [UIImageView new];
    _imgView = imgView;
    [self.contentView addSubview:imgView];
    UIImageView* imgGif = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"timeline_image_gif"]];;
    _imgGif = imgGif;
    [self.contentView addSubview:imgGif];
    [imgGif sizeToFit];
    
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
    [imgGif mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.trailing.equalTo(imgView);
    }];
    
}
- (void)setImgName:(NSString *)imgName{
    _imgName = imgName;
    
    [_imgView  sd_setImageWithURL:[NSURL URLWithString:imgName] placeholderImage:[UIImage imageNamed:@"avatar_default_big"]];
    if([imgName hasSuffix:@".gif"]){
        _imgGif.alpha = 1;
    }else{
        _imgGif.alpha = 0;
    }
}
@end
